<?php
session_start();
if(!isset($_SESSION['user'])){
    //session_destroy();
    Header("Location: login.php");
}
ob_start();

include_once 'Core/Config.php';
include_once 'Controller/ControladorFather.php';
include_once 'Model/ModelFather.php';
include_once 'Model/Publicacao.php';
include_once 'Model/Categoria.php';
include_once 'Model/Autor.php';
include_once 'Model/Usuario.php';

date_default_timezone_set('America/Campo_Grande');
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="index.css" />
        <!-- jquery for equal height elements -->
        <script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
        <script type="text/javascript" src="js/formee.js"></script>
        <script type="text/javascript" src="js/jquery.click-calendario-1.0.js"></script>
        <script src="js/jQuery_vForms.js" type="text/javascript"></script>

        <!-- css for structure -->
        <link rel="stylesheet" href="css/formee-structure.css" type="text/css" media="screen" />

        <!-- css for style -->
        <link rel="stylesheet" href="css/formee-style.css" type="text/css" media="screen" />
        
        <link href="css/jquery.click-calendario-1.0.css" rel="stylesheet" type="text/css"/>
        <title>Biblioteca LATEC</title>
    </head>

    <body>

        <div id="wrap">
            <div id="header">
                <div id="logo">
                    <h1>Biblioteca LATEC</h1>
                </div>
                <div id="menu">
                    <ul>
                        <li><a a href="?c=Publicacao&a=add">Inserir Publicação</a></li>
                        <li>|</li>
                        <li><a a href="?c=Publicacao&a=listC&p=0">Listar Publicação</a></li>
                        <li>|</li>
                        <li><a a href="?c=Categoria&a=add&p=0">Criar Categoria</a></li>
                        <li>|</li>
                        <li><a a href="?c=Categoria&a=listC&p=0">Listar Categoria</a></li>
                        <li>|</li>
                        <li><a a href="?c=Autor&a=add&p=0">Inserir Autor</a></li>
                        <li>|</li>
                        <li><a a href="?c=Autor&a=listC&p=0">Listar Autor</a></li>
                        <li>|</li>
                        <li><a a href="?c=Usuario&a=add&p=0">Inserir Usuário</a></li>
                        <li>|</li>
                        <li><a a href="?c=Usuario&a=listC&p=0">Listar Usuário</a></li>
                        <li>|</li>
                        <li><a a href="logout.php">Deslogar</a></li>
                    </ul>
                </div>
            </div>
            <div class="clear"></div>
            <div id="content">

                <?php
                $controller = (isset($_GET['c'])) ? $_GET['c'] : "";
                $action = (isset($_GET['a'])) ? $_GET['a'] : "index";
                $param = (isset($_GET['p'])) ? $_GET['p'] : "";
                if ($param != "")
                    $param = explode(",", $param);


                if ($c = $controller) {
                    include_once 'Controller/Controlador' . $controller . '.php';
                    $controller = 'Controlador' . $controller;
                    $controller = new $controller();
                    if (method_exists($controller, $action))
                        $controller->$action($param);
                    else
                        $controller->index($param);
                }
                ?>
            </div>
        </div>

    </body>
</html>
